package com.xzr.aspectj;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author：jojo
 * @Date：2022/1/20 16:42
 * @Description :TODO
 */
public class MyAspectJ {


    public void myBefore(JoinPoint joinPoint){
        System.out.println("前置通知执行了");
    }

    public void myAfterReturning(JoinPoint joinPoint){
        System.out.println("后置通知执行了");
    }


    public Object myAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
        System.out.println("环绕通知执行了");
        Object[] args = proceedingJoinPoint.getArgs();
        System.out.println(args[0]);
        args[0] = 1;
        args[1] = 2;
        Object proceed = proceedingJoinPoint.proceed(args);
        System.out.println("环绕通知结束");
        return proceed;
    }

    public void myAfterThrowing(JoinPoint joinPoint,Throwable e){
        System.out.println("异常通知");
        System.out.println("报错信息" + e.getMessage());
    }

    public void myAfter(){
        System.out.println("最终通知   不管怎样都会执行");
    }

}
